<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitAgentPay extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('agent_pay_records', function (Blueprint $table) {
            $table->comment = '订单代付记录';
            
            $table->increments('id');
            $table->uuid('uuid')->index();

            $table->integer('user_id')->unsigned()->index()->comment('原订单id'); //订单id
            $table->integer('order_id')->unsigned()->index()->comment('原订单id'); //订单id
            $table->integer('agent_order_id')->nullable()->unsigned()->index()->comment('代付订单id'); //管理员id

            $table->integer('agent_user_id')->nullable()->index()->comment('代付用户的id');
            $table->string('remark', 100)->nullable()->comment('备注');

            $table->boolean('is_open_box')->default(0)->index()->comment('盲盒是否已开盒');

            $table->integer('status')->default(0)->index()->comment('代付状态 0为代支付  1为支付中  2为支付成功  3为过期失效'); //管理员id
            $table->timestamp('paid_at')->nullable()->comment('代付的支付时间');

            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::disableForeignKeyConstraints();
        Schema::dropIfExists('agent_pay_records');
    }
}
